<?php
 
include_once("./configure/configure.php");						//--> global var
include_once("./admin/tools/smarty/libs/Smarty.class.php");		//--> out template
include_once("./admin/lib/utils/FileUtils.php");				//--> file utils

include_once("./lib/impl/CouponImpl.php");
include_once("./lib/impl/CouponAttributeImpl.php");

include_once("impl/MerchantImpl.php");


include_once("includeSmarty.php");

$firstLetter = $_GET['firstLetter'];

$cacheId = $firstLetter;

/*----- out html -----*/
$SUB_DIR	= FileUtils::getDirByString($firstLetter) . '/';

$smarty->compile_dir  	= COMPILE_DIR . '/mer/' . $SUB_DIR;
$smarty->cache_dir  	= CACHE_DIR . '/mer/' . $SUB_DIR;


if(!$smarty->isCached('merchants.html', $cacheId, $cacheId)){	
	$oMerchantImpl 	= new MerchantImpl(DB_TAG_COUPON);
	
	include_once("includeTag.php");
	include_once("includeCategories.php");
	
	
	if(!preg_match('/^[a-zA-Z]+$/', $firstLetter)){
		$firstLetter = '#';
	}
	
	$oMerchantsFLetter 	= $oMerchantImpl->getMerchantsByFirstLetter($firstLetter);
	
	$smarty->assign('oMerchantsFLetter', $oMerchantsFLetter);
	$smarty->assign('oCatTree', $oCatTree);
	
	$smarty->assign('oTags', $oTags);
	
	$smarty->assign('firstLetter', strtoupper($firstLetter));
}

$smarty->assign('HOME_URL', HOME_URL);
$smarty->assign('HOME_URL_HTTP', HOME_URL_HTTP);


$smarty->display('merchants.html', $cacheId, $cacheId);
?>
